<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="keywords">
    <button id="search">搜索</button>
    <div>
        上次搜索：
        <span id="lastkey"></span>
    </div>

    <script>

        search.onclick = function () {
            document.cookie = 'keywords=' + keywords.value
        }

        window.onload = function () {
            lastkey.innerHTML = document.cookie.split('=')[1]
        }

    </script>
</body>

</html>